package com.ztesoft.web.resourcecheck;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.ztesoft.framework.exception.BaseAppException;
import com.ztesoft.web.common.vo.HostInfoPOJO;

@Service
@Scope
public class HostResCheck {

	//不同方式策略 cpu/内存/..
	private CheckStrategy checkStrategy;
	
	public void setCheckStrategy(CheckStrategy checkStrategy) {
		this.checkStrategy = checkStrategy;
	}
	
	/**
	 * @param hostInfoPOJO 主机信息
	 * @param checkType <i>该项不支持带有可变参数的命令,如果需要带有可变参由子类自行实现</i><br>
	 * 		获取CPU执行命令	0 DMSConstant.CHECK_CMD_CPU;<br>
	 * 		获取used-mem执行命令	1 DMSConstant.CHECK_CMD_USED_MEM;<br>
	 * 		监测内存命令	2 DMSConstant.CHECK_CMD_MEM;<br>
	 * ...待完善添加<br>
	 * @return
	 * @throws BaseAppException
	 */
	public String getCheckData(HostInfoPOJO hostInfo, int checkType) throws BaseAppException {
		return checkStrategy.check(hostInfo, checkType);
		
	}
	
	public String getCheckDataT(HostInfoPOJO hostInfo, String shellCommand) throws BaseAppException {
		return checkStrategy.checkT(hostInfo, shellCommand);
	}
	

	/**
	 * 执行系统命令获取informix锁模式信息 <b>外层需要做个校验，只允许informix数据库才执行此操作</b>
	 * @param hostInfoPOJO 主机信息
	 * @param dbName 库名
	 * @param tableName 表名
	 * @return
	 * @throws BaseAppException
	 */
	public String getIfxLMode(HostInfoPOJO hostInfo, String dbName, String tableName) throws BaseAppException {
		return checkStrategy.checkIfxLMode(hostInfo, dbName, tableName);
	}
	
}
